<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>Hello world!</div>

  <script>
    const elem = document.querySelector('div')

    // 只复制标签
    let newElem = elem.cloneNode()
    console.log(newElem)

    // 复制标签和内容
    newElem = elem.cloneNode(true)
    console.log(newElem)
  </script>
</body>

</html>